<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Alsdk/DescribeUserDomains')}">域名列表</a></li>
        <li><a href="{:url('Alsdk/AddLiveDomain')}">添加域名</a></li>
        <li class="active"><a href="{:url('Alsdk/AddLiveDomainMapping')}">域名映射</a></li>
    </ul>
    <form action="{:url('Alsdk/AddLiveDomainMapping')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="form-group">
            <label class="col-sm-2 control-label">当前域名:</label>
            <div class="col-md-6 col-sm-10">
                <input class="form-control" type="text" name="PushDomain" required value="{$domain}" readonly/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>映射域名:</label>
            <div class="col-md-6 col-sm-10">
                <select id="PullDomain" name="PullDomain" class="form-control">
                    <foreach name="list" item="vo">
                    <option value="{$vo->DomainName}" >{$vo->DomainName}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" class="btn btn-primary" id="js-ajax-submit">{:lang("SAVE")}</button>
            <a class="btn btn-default" href="{:url('Alsdk/DescribeUserDomains')}">返回</a>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    $('#js-ajax-submit').on('click', function () {
        var data = {
            PushDomain:$("input[name='PushDomain']").val(),
            PullDomain:$("#PullDomain option:selected").val(),
        }
        $.ajax({
            url: "{:url('Alsdk/AddLiveDomainMapping')}",
    //         dataType: 'json',
            data: data,
            type: "POST",
            success: function(data){
        console.log(data)
        return 
                if (data.code == '1') {
                    noty({
                        text: data.msg,
                        type: 'success',
                        layout: 'topCenter',
                        modal: true,
                        timeout: 800,
                        callback: {
                            afterClose: function () {
                                if (data.url) {
                                    //返回带跳转地址
                                    window.location.href = data.url;
                                } else {
                                    //刷新当前页
                                    reloadPage(window);
                                }
                            }
                        }
                    }).show();
                } else if (data.code == '0') {
                    art.dialog({
                        content: data.msg,
                        icon: 'warning',
                        ok: function () {
                            this.title(data.msg);
                            return true;
                        }
                    });
                }
            }
        });
    });
</script>
</body>
</html>
